﻿
var totalPriceAdults=0;
var totalPriceChild = 0;
var totalPriceBaby = 0;
//var totalPrice = 0;
TotalPriceAdults = function () {
    var priceAirAdults = parseInt($("#TotalTicketAirPricesAdults").html());
    var priceStationAdults = parseInt($("#TotalTicketStationPricesAdults").html());
    var priceCarAdults = parseInt($("#TotalTicketCarPricesAdults").html());
    var priceRestaurantAdults = parseInt($("#TotalMenuAdults").html());
    var priceHotelAdults = parseInt($("#TotalTicketHotelPricesAdults").html());
    var priceServiceAdults = parseInt($("#TotalDvkAdults").html());
    var priceTravelGuideAdults = parseInt($("#TotalTravelGuidePricesAdults").html());
    var priceCommissionAdults = parseInt($("#TotalHHAdults").html());
    var priceInsuranceAdults = parseInt($("#TotalInsurancePricesAdults").html());
    var priceVisaAdults = parseInt($("#TotalVisaAdults").html());
    var priceShipAdults = parseInt($("#TotalTicketShipPricesAdults").html());
    

    totalPriceAdults = priceAirAdults + priceStationAdults + priceCarAdults + priceRestaurantAdults + priceHotelAdults + priceServiceAdults + priceTravelGuideAdults + priceCommissionAdults + priceInsuranceAdults + priceVisaAdults + priceShipAdults;
    $("#TotalPriceCaculatorAdults").html(totalPriceAdults);
};
TotalPriceChild = function () {
    var priceAirChild = parseInt($("#TotalTicketAirPricesChild").html());
    var priceStationChild = parseInt($("#TotalTicketStationPricesChild").html());
    var priceCarChild = parseInt($("#TotalTicketCarPricesChild").html());
    var priceRestaurantChild = parseInt($("#TotalMenuChild").html());
    var priceHotelChild = parseInt($("#TotalTicketHotelPricesChild").html());
    var priceServiceChild = parseInt($("#TotalDvkChild").html());
    var priceTravelGuideChild = parseInt($("#TotalTravelGuidePricesChild").html());
    var priceCommissionChild = parseInt($("#TotalHHChild").html());
    var priceInsuranceChild = parseInt($("#TotalInsurancePricesChild").html());
    var priceVisaChild = parseInt($("#TotalVisaChild").html());
    var priceShipChild = parseInt($("#TotalTicketShipPricesChild").html());
    
    totalPriceChild = priceAirChild + priceStationChild + priceCarChild + priceRestaurantChild + priceHotelChild + priceServiceChild + priceTravelGuideChild + priceCommissionChild + priceInsuranceChild + priceVisaChild + priceShipChild;
    $("#TotalPriceCaculatorChild").html(totalPriceChild);
};
TotalPriceBaby = function () {
    var priceAirBaby = parseInt($("#TotalTicketAirPricesBaby").html());
    var priceStationBaby = parseInt($("#TotalTicketStationPricesBaby").html());
    var priceRestaurantBaby = parseInt($("#TotalMenuBaby").html());
    var priceHotelBaby = parseInt($("#TotalTicketHotelPricesBaby").html());
    var priceServiceBaby = parseInt($("#TotalDvkBaby").html());
    var priceCommissionBaby = parseInt($("#TotalHHBaby").html());
    var priceInsuranceBaby = parseInt($("#TotalInsurancePricesBaby").html());
    var priceVisaBaby = parseInt($("#TotalVisaBaby").html());
    var priceShipBaby = parseInt($("#TotalTicketShipPricesBaby").html());
    
    totalPriceBaby = priceAirBaby + priceStationBaby  + priceRestaurantBaby + priceHotelBaby + priceServiceBaby  + priceCommissionBaby + priceInsuranceBaby + priceVisaBaby + priceShipBaby;
    $("#TotalPriceCaculatorBaby").html(totalPriceBaby);
    
};
TotalPrice = function (quantityAdults,quantityChild,quantityBaby) {
    TotalPriceAdults();
    TotalPriceChild();
    TotalPriceBaby();
    var totalPriceCaculator = totalPriceAdults * quantityAdults + totalPriceChild * quantityChild + totalPriceBaby * quantityBaby;
    $("#TotalPriceCaculator").html(totalPriceCaculator);
    //var priceAir = parseInt($("#TotalTicketAirPrices").html());
    //var priceStation = parseInt($("#TotalTicketStationPrices").html());
    //var priceCar = parseInt($("#TotalTicketCarPrices").html());
    //var priceRestaurant = parseInt($("#TotalMenuPrices").html());
    //var priceHotel = parseInt($("#TotalTicketHotelPrices").html());
    //var priceService = parseInt($("#TotalDvkPrices").html());
    //var priceTravelGuide = parseInt($("#TotalTravelGuidePrices").html());
    //var priceCommission = parseInt($("#TotalHHPrices").html());
    //var priceInsurance = parseInt($("#TotalInsurancePrices").html());
    //var priceVisa = parseInt($("#TotalVisaPrices").html());
    //var priceShip = parseInt($("#TotalTicketShipPrices").html());
    
    //totalPrice = priceAir + priceStation + priceCar + priceRestaurant + priceHotel + priceService + priceTravelGuide + priceCommission + priceInsurance + priceVisa + priceShip;
    //$("#TotalPriceCaculator").html(totalPrice);
};
TotalSalePriceCalculator = function (salePriceAdultsElement, salePriceChildElement, salePariceBabyElement, totalSalePriceElement) {
    //ham tinh tong gia ban doan
     var fncTotalSalePriceCalculator = function () {
        var salePriceAdults = $(salePriceAdultsElement).val();
        var salePriceChild = $(salePriceChildElement).val();
        var salePariceBaby = $(salePariceBabyElement).val();
        var totalSalePrice = parseInt(salePriceAdults) + parseInt(salePriceChild) + parseInt(salePariceBaby);
        $(totalSalePriceElement).val(totalSalePrice);
         var profitAdults = 0;
         var profitChild = 0;
         var profitBaby = 0;
         var profit = 0;
         if (salePriceAdults > totalPriceAdults) {
             profitAdults = salePriceAdults - totalPriceAdults;
         }
         if (salePriceChild > totalPriceChild) {
             profitChild = salePriceChild - totalPriceChild;
         }
         if (salePariceBaby > totalPriceBaby) {
             profitBaby = salePariceBaby - totalPriceBaby;
         }
         profit = profitAdults + profitChild + profitBaby;
         $('#ProfitCaculatorAdults').html(profitAdults);
         $('#ProfitCaculatorChild').html(profitChild);
         $('#ProfitCaculatorBaby').html(profitBaby);
         $('#ProfitCaculator').html(profit);
     };
     $(salePriceAdultsElement).keyup(fncTotalSalePriceCalculator);
     $(salePriceChildElement).keyup(fncTotalSalePriceCalculator);
     $(salePariceBabyElement).keyup(fncTotalSalePriceCalculator);
};

 
    

    

    
    

    